package com.zhengshang.common.core.domain.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.zhengshang.common.annotation.Excel;
import com.zhengshang.common.annotation.Excel.ColumnType;
import com.zhengshang.common.annotation.Excel.Type;
import com.zhengshang.common.annotation.Excels;
import com.zhengshang.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 用户对象 sys_user
 *
 *
 */
public class SysUser extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 用户ID */
//    @Excel(name = "用户ID", cellType = ColumnType.NUMERIC, prompt = "用户编号")
    private Long userId;

    /** 部门ID */
    private Long deptId;

    /** 用户账号 */
    @Excel(name="用户账号", sort=1)
    private String userName;

    /** 用户昵称 */
    @Excel(name="用户昵称", sort=2)
    private String nickName;

    /** 用户邮箱 */
    private String email;

    /** 手机号码 */
    @Excel(name="手机号码", sort=3)
    private String phonenumber;

    /** 归属地 */
    @Excel(name="归属地", sort=4)
    private String phoneArea;

    /** 用户性别 */
//    @Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知")
    private String sex;

    /** 用户头像 */
    private String avatar;

    /** 密码 */
    private String password;

    /** 盐加密 */
    private String salt;

    /** 帐号状态（0正常 1停用） */
    @Excel(name="帐号状态", readConverterExp="0=正常,1=停用", sort=5)
    private String status;

    /** 删除标志（0代表存在 2代表删除） */
    private String delFlag;

    /** 最后登录IP */
//    @Excel(name = "最后登录IP", type = Type.EXPORT)
    private String loginIp;

    /** 最后登录时间 */
//    @Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT)
    private Date loginDate;

    /** 用户类型（00系统用户，01 APP用户） **/
    private String userType;

    /** 推广码 **/
    @Excel(name="推广码", sort=97)
    private String promoCode;

    /** 上级推广人ID **/
    private Long upUserId;

    /** 上级推广人ID **/
    private Long upUpUserId;

    /** APP用户会员类型(1会员，2星级会员，3VIP) **/
    @Excel(name="APP用户会员类型", readConverterExp="1=会员,2=星级会员,3=VIP", sort=6)
    private String appMemberType;

    /** APP用户账户余额 **/
    private BigDecimal appAccountBalance;

    /** APP用户已提现金额 **/
    private BigDecimal appWithdrawalMoney;

    /** APP用户冻结金额 **/
    private BigDecimal appFrozenAmount;

    /** 团队人数 **/
    private Integer teamNum;

    /** 发展会员数量 **/
    private Integer childNum;


    /** 优惠券数量 **/
    private Integer couponCount;


    /** 总签到次数 **/
    private Integer signCount;

    /** 是否是合伙人（0不是，1是） **/
    @Excel(name="是否是合伙人", readConverterExp="0=不是,1=是", sort=7)
    private String isPartner;

    /** 合伙人开通时间 **/
//    @Excel(name="合伙人开通时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT, defaultValue = "未开通", sort=7)
    private Date partainOpeningTime;

    /** 推广贡献值 **/
    @Excel(name="贡献值", sort=8)
    private BigDecimal contributionValue;

    /** 所属合伙人的ID **/
    private Long pertainToPartnerId;

    /** 合伙人等级 **/
    private Integer partnerLevel;

    /** 真实姓名 **/
    private String realName;

    /** 支付宝账号 **/
    private String alipay;

    /** 银行ID **/
    private Long bankId;

    /** 银行卡 **/
    private String bankCard;

    /** 微信账号 **/
    private String wxpay;

    /** 部门对象 */
//    @Excels({
//        @Excel(name = "{dept.name}", targetAttr = "deptName", type = Type.EXPORT),
//        @Excel(name = "{dept.leader}", targetAttr = "leader", type = Type.EXPORT)
//    })
    private SysDept dept;

    /** 角色对象 */
    private List<SysRole> roles;

    /** 角色组 */
    private Long[] roleIds;

    /** 岗位组 */
    private Long[] postIds;

    /** 登录token */
    private String token;


    private  String deviceID;

    @Excels({@Excel(name="所属直推", targetAttr="phonenumber", defaultValue="无", type=Excel.Type.EXPORT, sort=9)})
    private SysUser upUser;

    @Excels({@Excel(name="所属间推", targetAttr="phonenumber", defaultValue="无", type=Excel.Type.EXPORT, sort=10)})
    private SysUser upUpUser;

    @Excels({@Excel(name="所属合伙人", targetAttr="phonenumber", defaultValue="无", type=Excel.Type.EXPORT, sort=10)})
    private SysUser pertainUser;

    /** 所有所属上级账号 */
    private String allSuperiorUserIds;

    /** 用户冻结佣金 */
    private BigDecimal appFrozenCommission;

    public SysUser()
    {

    }

    public SysUser(Long userId)
    {
        this.userId = userId;
    }

    public Long getUserId()
    {
        return userId;
    }

    public void setUserId(Long userId)
    {
        this.userId = userId;
    }

    public boolean isAdmin()
    {
        return isAdmin(this.userId);
    }

    public static boolean isAdmin(Long userId)
    {
        return userId != null && 1L == userId;
    }

    public Long getDeptId()
    {
        return deptId;
    }

    public void setDeptId(Long deptId)
    {
        this.deptId = deptId;
    }

    @Size(min = 0, max = 30, message = "{user.nickname.length}" )
    public String getNickName()
    {
        return nickName;
    }

    public void setNickName(String nickName)
    {
        this.nickName = nickName;
    }

    @NotBlank(message = "{user.username.notnull}")
    @Size(min = 0, max = 30, message = "{user.username.length}")
    public String getUserName()
    {
        return userName;
    }

    public void setUserName(String userName)
    {
        this.userName = userName;
    }

    @Email(message = "{user.email.format}")
    @Size(min = 0, max = 50, message = "{user.email.length}")
    public String getEmail()
    {
        return email;
    }

    public void setEmail(String email)
    {
        this.email = email;
    }

    @Size(min = 0, max = 11, message = "{user.phone.length}")
    public String getPhonenumber()
    {
        return phonenumber;
    }

    public void setPhonenumber(String phonenumber)
    {
        this.phonenumber = phonenumber;
    }

    public String getPhoneArea() {
        return phoneArea;
    }

    public void setPhoneArea(String phoneArea) {
        this.phoneArea = phoneArea;
    }

    public String getSex()
    {
        return sex;
    }

    public void setSex(String sex)
    {
        this.sex = sex;
    }

    public String getAvatar()
    {
        return avatar;
    }

    public void setAvatar(String avatar)
    {
        this.avatar = avatar;
    }

	@JsonIgnore
    @JsonProperty
    public String getPassword()
    {
        return password;
    }

    public void setPassword(String password)
    {
        this.password = password;
    }

    public String getSalt()
    {
        return salt;
    }

    public void setSalt(String salt)
    {
        this.salt = salt;
    }

    public String getStatus()
    {
        return status;
    }

    public void setStatus(String status)
    {
        this.status = status;
    }

    public String getDelFlag()
    {
        return delFlag;
    }

    public void setDelFlag(String delFlag)
    {
        this.delFlag = delFlag;
    }

    public String getLoginIp()
    {
        return loginIp;
    }

    public void setLoginIp(String loginIp)
    {
        this.loginIp = loginIp;
    }

    public Date getLoginDate()
    {
        return loginDate;
    }

    public void setLoginDate(Date loginDate)
    {
        this.loginDate = loginDate;
    }

    public String getUserType() {
        return userType;
    }

    public void setUserType(String userType) {
        this.userType = userType;
    }

    public String getPromoCode() {
        return promoCode;
    }

    public void setPromoCode(String promoCode) {
        this.promoCode = promoCode;
    }

    public Long getUpUserId() {
        return upUserId;
    }

    public void setUpUserId(Long upUserId) {
        this.upUserId = upUserId;
    }

    public Long getUpUpUserId() {
        return upUpUserId;
    }

    public void setUpUpUserId(Long upUpUserId) {
        this.upUpUserId = upUpUserId;
    }

    public SysDept getDept()
    {
        return dept;
    }

    public void setDept(SysDept dept)
    {
        this.dept = dept;
    }

    public List<SysRole> getRoles()
    {
        return roles;
    }

    public void setRoles(List<SysRole> roles)
    {
        this.roles = roles;
    }

    public Long[] getRoleIds()
    {
        return roleIds;
    }

    public void setRoleIds(Long[] roleIds)
    {
        this.roleIds = roleIds;
    }

    public Long[] getPostIds()
    {
        return postIds;
    }

    public void setPostIds(Long[] postIds)
    {
        this.postIds = postIds;
    }

    public String getAppMemberType() {
        return appMemberType;
    }

    public void setAppMemberType(String appMemberType) {
        this.appMemberType = appMemberType;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public BigDecimal getAppAccountBalance() {
        return appAccountBalance;
    }

    public void setAppAccountBalance(BigDecimal appAccountBalance) {
        this.appAccountBalance = appAccountBalance;
    }

    public BigDecimal getAppWithdrawalMoney() {
        return appWithdrawalMoney;
    }

    public void setAppWithdrawalMoney(BigDecimal appWithdrawalMoney) {
        this.appWithdrawalMoney = appWithdrawalMoney;
    }

    public BigDecimal getAppFrozenAmount() {
        return appFrozenAmount;
    }

    public void setAppFrozenAmount(BigDecimal appFrozenAmount) {
        this.appFrozenAmount = appFrozenAmount;
    }

    public Integer getTeamNum() {
        return teamNum;
    }

    public void setTeamNum(Integer teamNum) {
        this.teamNum = teamNum;
    }

    public String getIsPartner() {
        return isPartner;
    }

    public void setIsPartner(String isPartner) {
        this.isPartner = isPartner;
    }

    public BigDecimal getContributionValue() {
        return contributionValue;
    }

    public void setContributionValue(BigDecimal contributionValue) {
        this.contributionValue = contributionValue;
    }

    public Long getPertainToPartnerId() {
        return pertainToPartnerId;
    }

    public void setPertainToPartnerId(Long pertainToPartnerId) {
        this.pertainToPartnerId = pertainToPartnerId;
    }

    public Integer getPartnerLevel() {
        return partnerLevel;
    }

    public void setPartnerLevel(Integer partnerLevel) {
        this.partnerLevel = partnerLevel;
    }

    public String getRealName() {
        return realName;
    }

    public void setRealName(String realName) {
        this.realName = realName;
    }

    public String getAlipay() {
        return alipay;
    }

    public void setAlipay(String alipay) {
        this.alipay = alipay;
    }

    public String getBankCard() {
        return bankCard;
    }

    public void setBankCard(String bankCard) {
        this.bankCard = bankCard;
    }

    public String getWxpay() {
        return wxpay;
    }

    public void setWxpay(String wxpay) {
        this.wxpay = wxpay;
    }

    public Long getBankId() {
        return bankId;
    }

    public void setBankId(Long bankId) {
        this.bankId = bankId;
    }

    public SysUser getUpUser() {
        return upUser;
    }

    public void setUpUser(SysUser upUser) {
        this.upUser = upUser;
    }

    public SysUser getUpUpUser() {
        return upUpUser;
    }

    public void setUpUpUser(SysUser upUpUser) {
        this.upUpUser = upUpUser;
    }

    public Date getPartainOpeningTime() {
        return partainOpeningTime;
    }

    public void setPartainOpeningTime(Date partainOpeningTime) {
        this.partainOpeningTime = partainOpeningTime;
    }

    public String getAllSuperiorUserIds() {
        return allSuperiorUserIds;
    }

    public void setAllSuperiorUserIds(String allSuperiorUserIds) {
        this.allSuperiorUserIds = allSuperiorUserIds;
    }

    public BigDecimal getAppFrozenCommission() {
        return appFrozenCommission;
    }

    public void setAppFrozenCommission(BigDecimal appFrozenCommission) {
        this.appFrozenCommission = appFrozenCommission;
    }

    public SysUser getPertainUser() {
        return pertainUser;
    }

    public void setPertainUser(SysUser pertainUser) {
        this.pertainUser = pertainUser;
    }

    public String getDeviceID() {
        return deviceID;
    }

    public void setDeviceID(String deviceID) {
        this.deviceID = deviceID;
    }

    public Integer getSignCount() {
        return signCount;
    }

    public void setSignCount(Integer signCount) {
        this.signCount = signCount;
    }

    public Integer getCouponCount() {
        return couponCount;
    }

    public void setCouponCount(Integer couponCount) {
        this.couponCount = couponCount;
    }

    public Integer getChildNum() {
        return childNum;
    }

    public void setChildNum(Integer childNum) {
        this.childNum = childNum;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
            .append("userId", getUserId())
            .append("deptId", getDeptId())
            .append("userName", getUserName())
            .append("nickName", getNickName())
            .append("email", getEmail())
            .append("phonenumber", getPhonenumber())
            .append("sex", getSex())
            .append("childNum", getSex())
            .append("avatar", getAvatar())
            .append("password", getPassword())
            .append("salt", getSalt())
            .append("status", getStatus())
            .append("delFlag", getDelFlag())
            .append("loginIp", getLoginIp())
            .append("deviceID", getDeviceID())
            .append("loginDate", getLoginDate())
            .append("createBy", getCreateBy())
            .append("createTime", getCreateTime())
            .append("updateBy", getUpdateBy())
            .append("updateTime", getUpdateTime())
            .append("remark", getRemark())
            .append("dept", getDept())
            .append("userType", getUserType())
            .append("promoCode", getPromoCode())
            .append("upUserId", getUpUserId())
            .append("signCount", getSignCount())
            .append("couponCount", getCouponCount())
            .append("upUpUserId", getUpUpUserId())
            .append("appMemberType", getAppMemberType())
            .append("token", getToken())
            .append("appAccountBalance", getAppAccountBalance())
            .append("appWithdrawalMoney", getAppWithdrawalMoney())
            .append("appFrozenAmount", getAppFrozenAmount())
            .append("teamNum", getTeamNum())
            .append("isPartner", getIsPartner())
            .append("partainOpeningTime", getPartainOpeningTime())
            .append("contributionValue", getContributionValue())
            .append("pertainToPartnerId", getPertainToPartnerId())
            .append("partnerLevel", getPartnerLevel())
            .append("realName", getRealName())
            .append("alipay", getAlipay())
            .append("bankCard", getBankCard())
            .append("bankId", getBankId())
            .append("upUser", getUpUser())
            .append("upUpUser", getUpUpUser())
            .append("pertainUser", getPertainUser())
            .append("wxpay", getWxpay())
            .append("allSuperiorUserIds", getAllSuperiorUserIds())
            .append("appFrozenCommission", getAppFrozenCommission())
            .toString();
    }
}
